package com.hanbang.maige.view.quanzi.adapter;

import android.content.Context;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.hanbang.maige.R;
import com.hanbang.maige.code.base.baseadapter.ViewHolder;
import com.hanbang.maige.code.base.baseadapter.recyclerview.CommonAdapter;
import com.hanbang.maige.utils.bitmap.GlideOptions;
import com.hanbang.maige.utils.bitmap.GlideUtils;
import com.hanbang.maige.widget.gridlayout.SuperGridLayout;

import java.util.List;

/**
 * 作者　　: 李坤
 * 创建时间:2016/10/31　17:41
 * 邮箱　　：496546144@qq.com
 * <p>
 * 功能介绍：
 */

public class FaBuNineGridAdapter extends CommonAdapter<String> {


    SuperGridLayout superGridLayout;

    public FaBuNineGridAdapter(Context context, List<String> datas, SuperGridLayout superGridLayout) {
        super(context, R.layout.item_image, datas);
        this.superGridLayout = superGridLayout;
    }


    @Override
    public void convert(ViewHolder holder, String s) {
        ViewGroup.LayoutParams p = holder.getConvertView().getLayoutParams();
        p.height = superGridLayout.getmItemSize();
        p.width = superGridLayout.getmItemSize();
        holder.getConvertView().setLayoutParams(p);
        if ("add".equals(s)) {
            ((ImageView) holder.getConvertView()).setImageResource(R.drawable.material_add_photo);
        } else {
            GlideUtils.show(((ImageView) holder.getConvertView()), s, new GlideOptions.Builder()
                    .setHeight(superGridLayout.getmItemSize()).setWidth(superGridLayout.getmItemSize()).setPlaceholder1_1().bulider());
        }
    }
}
